﻿create role [EventScavengerViewers]
GO
exec sp_addrolemember  @rolename = 'db_datareader', @membername = 'EventScavengerViewers'
GO
create role [EventScavengerAdmins]
GO
exec sp_addrolemember  @rolename = 'db_datawriter', @membername = 'EventScavengerAdmins'
GO
create role [EventScavengerCollectorUsers]
GO
exec sp_addrolemember  @rolename = 'db_datawriter', @membername = 'EventScavengerCollectorUsers'
GO

--************* EventScavengerViewers ***************
GRANT EXECUTE ON [dbo].[GetEventlogRowCount] TO EventScavengerViewers AS [dbo]
GO
GRANT EXECUTE ON [dbo].[SelectEventIDList] TO EventScavengerViewers AS [dbo]
GO
GRANT EXECUTE ON [dbo].[SelectEventLogEntries2] TO EventScavengerViewers AS [dbo]
GO
GRANT EXECUTE ON [dbo].[SelectMachineLogEntry] TO EventScavengerViewers AS [dbo]
GO
GRANT EXECUTE ON [dbo].[SelectMachineLogList3] TO EventScavengerViewers AS [dbo]
GO
GRANT EXECUTE ON [dbo].[SelectSourceList] TO EventScavengerViewers AS [dbo]
GO

--************* EventScavengerAdmins ***************
grant execute on [dbo].[SelectGlobalSettings] to EventScavengerAdmins AS [dbo]
go
grant execute on [dbo].[UpdateGlobalSettings] to EventScavengerAdmins AS [dbo]
go
GRANT EXECUTE ON [dbo].[DeleteCollector] TO EventScavengerAdmins AS [dbo]
GO
GRANT EXECUTE ON [dbo].[DeleteImportLogs] TO EventScavengerAdmins AS [dbo]
GO
GRANT EXECUTE ON [dbo].[DeleteMachineLog] TO EventScavengerAdmins AS [dbo]
GO
GRANT EXECUTE ON [dbo].[GetEventlogRowCount] TO EventScavengerAdmins AS [dbo]
GO
GRANT EXECUTE ON [dbo].[GetRunCreateHistoryEnabled] TO EventScavengerAdmins AS [dbo]
GO
GRANT EXECUTE ON [dbo].[GetSettingValue] TO EventScavengerAdmins AS [dbo]
GO
GRANT EXECUTE ON [dbo].[InsertCollector] TO EventScavengerAdmins AS [dbo]
GO
GRANT EXECUTE ON [dbo].[InsertImportLogs] TO EventScavengerAdmins AS [dbo]
GO
GRANT EXECUTE ON [dbo].[SelectCollectors] TO EventScavengerAdmins AS [dbo]
GO
GRANT EXECUTE ON [dbo].[SelectMachineLogEntry] TO EventScavengerAdmins AS [dbo]
GO
GRANT EXECUTE ON [dbo].[SelectMachineLogList2] TO EventScavengerAdmins AS [dbo]
GO
GRANT EXECUTE ON [dbo].[SetCreateHistorySettings] TO EventScavengerAdmins AS [dbo]
GO
GRANT EXECUTE ON [dbo].[SetMaintenanceSettings] TO EventScavengerAdmins AS [dbo]
GO
GRANT EXECUTE ON [dbo].[SetRecyclingCheckFrequencyMinutes] TO EventScavengerAdmins AS [dbo]
GO
GRANT EXECUTE ON [dbo].[SetRepeatTimeSec] TO EventScavengerAdmins AS [dbo]
GO
GRANT EXECUTE ON [dbo].[UpdateCollector] TO EventScavengerAdmins AS [dbo]
GO
GRANT EXECUTE ON [dbo].[UpdateImportLogs] TO EventScavengerAdmins AS [dbo]
GO
GRANT EXECUTE ON [dbo].[UpdateMachineLogEntry] TO EventScavengerAdmins AS [dbo]
GO
GRANT EXECUTE ON [dbo].[SetSettingValue] TO EventScavengerAdmins AS [dbo]
GO
GRANT EXECUTE ON [dbo].[SelectImportLogs] TO EventScavengerAdmins AS [dbo]
GO
grant execute on dbo.SelectPollingFilters to EventScavengerAdmins AS [dbo]
GO
grant execute on dbo.UpdatePollFilter to EventScavengerAdmins AS [dbo]
GO
grant execute on dbo.InsertPollFilter to EventScavengerAdmins AS [dbo]
GO
grant execute on dbo.DeletePollFilter to EventScavengerAdmins AS [dbo]
GO
GRANT EXECUTE ON [dbo].[SelectSourceList2] TO EventScavengerViewers AS [dbo]
GO
grant execute on [dbo].SelectMachineLogListAll to EventScavengerAdmins AS [dbo]
go

--************* EventScavengerCollectorUsers ***************
GRANT EXECUTE ON [dbo].[SelectImportLogsByCollector] TO EventScavengerCollectorUsers AS [dbo]
GO
GRANT EXECUTE ON [dbo].[SelectMachineLogEntry] TO EventScavengerCollectorUsers AS [dbo]
GO
GRANT EXECUTE ON [dbo].[SelectMachineLogListByCollector] TO EventScavengerCollectorUsers AS [dbo]
GO
GRANT EXECUTE ON [dbo].[InsertMachineLog] TO EventScavengerCollectorUsers AS [dbo]
GO
GRANT EXECUTE ON [dbo].[SetLastPollTimeForMachineLog] TO EventScavengerCollectorUsers AS [dbo]
GO
GRANT EXECUTE ON [dbo].[GetMachineLogMaxTimeGenerated] TO EventScavengerCollectorUsers AS [dbo]
GO
GRANT EXECUTE ON [dbo].[InsertEventLogEntry] TO EventScavengerCollectorUsers AS [dbo]
GO
GRANT EXECUTE ON [dbo].[InsertEventLogEntries] TO EventScavengerCollectorUsers AS [dbo]
GO
GRANT EXECUTE ON [dbo].[DoMaintenance] TO EventScavengerCollectorUsers AS [dbo]
GO
GRANT EXECUTE ON [dbo].[GetSettingValue] TO EventScavengerCollectorUsers AS [dbo]
GO
GRANT EXECUTE ON [dbo].[SetMaintenanceLastRunTime] TO EventScavengerCollectorUsers AS [dbo]
GO
GRANT EXECUTE ON [dbo].[GetCollectorNextRecycleTime] TO EventScavengerCollectorUsers AS [dbo]
GO
GRANT EXECUTE ON [dbo].[GetCollectorThreadRecyclingEnabled] TO EventScavengerCollectorUsers AS [dbo]
GO
GRANT EXECUTE ON [dbo].[SetCollectorNextRecycleTime] TO EventScavengerCollectorUsers AS [dbo]
GO
GRANT EXECUTE ON [dbo].[SetNextCreateHistoryTime] TO EventScavengerCollectorUsers AS [dbo]
GO
GRANT EXECUTE ON [dbo].[DoCreateHistory] TO EventScavengerCollectorUsers AS [dbo]
GO
GRANT EXECUTE ON [dbo].[GetCollectorByName] TO EventScavengerCollectorUsers AS [dbo]
GO
GRANT EXECUTE ON [dbo].[DoArchiveEntriesByDates] TO EventScavengerCollectorUsers AS [dbo]
GO
--Remote entries
GRANT EXECUTE ON [dbo].[SelectEventLogEntriesByMachineLogName] TO EventScavengerCollectorUsers AS [dbo]
GO
grant execute on dbo.SelectPollFilter TO EventScavengerCollectorUsers AS [dbo]
GO
grant execute on dbo.SelectPollFilterEventIDsByPollFilterID TO EventScavengerCollectorUsers AS [dbo]
GO
grant execute on dbo.SelectPollFilterSourcesByPollFilterID TO EventScavengerCollectorUsers AS [dbo]
GO